#! /bin/bash

echo "===== Starting build ====="
echo "Timestamp"
date -u
echo "=========================="
echo

echo "===== Updating from SVN ====="
svn update
cd src

echo
echo "===== Making JETI Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=JETI PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-jeti.hex

echo
echo "===== Making FRSKY Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=FRSKY TEMPLATES=NO PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-frsky.hex

echo
echo "===== Making FRSKY SerialSound Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=FRSKY TEMPLATES=NO PHASES=YES SERVOICE=YES
echo ">>>  moving"
mv er9x.hex ../er9x-frsky-sv.hex

#echo
#echo "===== Making FRSKY - NOHELI/NOTEMPLATE Version ====="
#echo ">>> cleaning"
#make clean
#echo ">>>  making"
#make EXT=FRSKY TEMPLATES=NO HELI=NO PHASES=YES
#echo ">>>  moving"
#mv er9x.hex ../er9x-frsky-noht.hex



echo
echo "===== Making ARDUPILOT Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=ARDUPILOT PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-ardupilot.hex

echo
echo "===== Making nmea Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=NMEA PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-nmea.hex


#echo
#echo "===== Making MAIN - NOHELI/NOTEMPLATE Version ====="
#echo ">>> cleaning"
#make clean
#echo ">>>  making"
#make TEMPLATES=NO HELI=NO PHASES=YES
#echo ">>>  moving"
#mv er9x.hex ../er9x-noht.hex

echo
echo "===== Making MAIN Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x.hex

echo
echo "===== Making 128 Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make CPU=128 EXT=FRSKY PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-128.hex

echo
echo "===== Making 2561 Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make CPU=2561 EXT=FRSKY PHASES=YES
echo ">>>  moving"
mv er9x.hex ../er9x-2561.hex

#echo
#echo "===== Making 128 Version ====="
#echo ">>> cleaning"
#make clean
#echo ">>>  making"
#make CPU=128 PHASES=YES
#echo ">>>  moving"
#mv er9x.hex ../er9x-128-standard.hex

echo
echo "===== Making FRSKY DE Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=FRSKY TEMPLATES=NO PHASES=YES LANG=DE
echo ">>>  moving"
mv er9x.hex ../er9x-frsky-de.hex

echo
echo "===== Making FRSKY FR Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make EXT=FRSKY TEMPLATES=NO PHASES=YES LANG=FR
echo ">>>  moving"
mv er9x.hex ../er9x-frsky-fr.hex


echo
echo "===== Making MAIN DE Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make PHASES=YES LANG=DE
echo ">>>  moving"
mv er9x.hex ../er9x-de.hex

echo
echo "===== Making 128 DE Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make CPU=128 EXT=FRSKY PHASES=YES LANG=DE
echo ">>>  moving"
mv er9x.hex ../er9x-128-de.hex

echo
echo "===== Making MAIN NO Version ====="
echo ">>> cleaning"
make clean
echo ">>>  making"
make PHASES=YES LANG=NO
echo ">>>  moving"
mv er9x.hex ../er9x-no.hex


echo ">>> cleaning"
make clean 

cd ..
